package cmw.com.base;

import android.content.Context;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.TextView;

import cmw.com.beijingnew.R;
import cmw.com.beijingnew.activity.MainActivity;

/**
 * Created by Administrator on 2017/4/8.
 */

public class BasePager {

    protected Context context;

    public View rootView;

    /**
     * 标题
     */
    protected TextView tv_title;

    /**
     *  标题左侧菜单
     */
    protected ImageButton ib_menu;

    /**
     * 内容FrameLayout
     */
    protected FrameLayout fl_content;


    public BasePager(Context context){
        this.context = context;
        this.rootView = initView();
        initEvents();
    }

    private View initView() {
        View view = View.inflate(context, R.layout.base_pager, null);
        tv_title = (TextView)view.findViewById(R.id.tv_title);
        ib_menu = (ImageButton) view.findViewById(R.id.ib_menu);
        fl_content = (FrameLayout) view.findViewById(R.id.fl_content);
        return view;
    }

    private void initEvents(){
        ib_menu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MainActivity mainActivity = (MainActivity)context;
                mainActivity.toggle();
            }
        });

    }

    /**
     * 数据初始化，供子类重写
     */
    public void initData(){

    }


}
